//
//  BVBannerCell.m
//  BuyVegetable
//
//  Created by yushanchang on 16/9/29.
//  Copyright © 2016年 com.yinding. All rights reserved.
//

#import "BVBannerCell.h"
#import "SDCycleScrollView.h"

@interface BVBannerCell ()<SDCycleScrollViewDelegate>

@end

@implementation BVBannerCell

- (void)setDataSource:(NSMutableArray *)dataSource{
    _dataSource = dataSource;
    
    SDCycleScrollView * bannerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, ScreenW, 180) imagesGroup:dataSource];
    
    // 添加属性
    bannerView.delegate = self;
    bannerView.showPageControl = YES;
    bannerView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
    bannerView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
    bannerView.dotColor = [UIColor BVBaseOrangeColor];
    bannerView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
    [self.contentView addSubview:bannerView];

}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    // 区分点击不同的广告
    NSLog(@"index = %ld", index);
    if(self.delegate && [self.delegate respondsToSelector:@selector(indexBannerCell:didSelectedIndex:)]){
        [self.delegate indexBannerCell:self didSelectedIndex:index];
    }
}

@end
